<template>
    <div class="standard_list">
        <OrgTable ref="OrgTabRef" :get-data="pageList" :form-data="formData" :remove="remove">
            <template v-slot:from_search>
                <el-form-item>
                    <el-input v-model="formData.tableName" placeholder="报表名称" clearable />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="search" :icon="'Search'">查询</el-button>
                </el-form-item>
                <el-form-item>
                    <el-button type="success" @click="add" :icon="'Plus'" v-permission="'enact:task:add'">新增临时任务</el-button>
                </el-form-item>
            </template>
            <template v-slot:columns>
                <el-table-column property="tableName" label="报表名称" align="center">
                    <template #default="scope">
                        <el-link type="primary" @click="toDetail(scope.row)">{{ scope.row.tableName }}</el-link>
                    </template>
                </el-table-column>
                <el-table-column property="tableVersion" label="报表版本" width="100" align="center" />
                <el-table-column property="collectObj.des" label="采集对象" width="100" align="center" />
                <el-table-column property="batchNumber" label="批次号" width="150" align="center" />
                <el-table-column property="type.des" label="任务类型" width="120" align="center" />
                <el-table-column property="createTime" label="生成时间" width="200" align="center" />
                <el-table-column label="操作" align="center" width="120">
                    <template #default="scope">
                        <!-- <el-button size="small" @click="handleEdit(scope.row)" :disabled="scope.row.type.code == 'PLAN'"
                            v-permission="'enact:table:edit'">
                            编辑
                        </el-button> -->
                        <el-button size="small" type="danger" @click="handleDelete(scope.row)"
                            :disabled="userStore.id == scope.row.id" v-permission="'enact:task:del'">
                            删除
                        </el-button>
                    </template>
                </el-table-column>
            </template>
        </OrgTable>
    </div>
</template>
<script setup>
import { ref, reactive, onMounted } from "vue"
import OrgTable from '@/components/OrgTable.vue'
import { useRouter } from 'vue-router'
import { pageList, remove } from '@/api/enact/task'
import { useUserStore } from '@/stores/user.js';

const router = useRouter()
const userStore = useUserStore();

const OrgTabRef = ref(null)

const formData = reactive({
    tableName: undefined,
})

const search = () => {
    OrgTabRef.value.queryData()
}
const toDetail = (row) => {
    router.push('/task-detail/' + row.id)
}
const add = () => {
    router.push('/task-add')
}

const handleDelete = (row) => {
    OrgTabRef.value.handleDelete(row)
}
// const handleEdit = (row) => {
//     router.push("/user-edit/" + row.id)
// }


</script>
<style scoped>
.standard_list {
    height: 100%;
}
</style>
